package com.xianbeiying.app.ckgl.model;

import android.content.Context;
import android.util.Log;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.xianbeiying.app.ckgl.MyApplication;
import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.bean.JsonBean;
import com.xianbeiying.app.ckgl.bean.JsonDataBean;
import com.xianbeiying.app.ckgl.bean.UrlBean;
import com.xianbeiying.app.ckgl.http.HttpPostManger;
import com.xianbeiying.app.ckgl.util.DialogUtile;
import com.xianbeiying.app.ckgl.util.LogUtils;
import com.xianbeiying.app.ckgl.util.MyDialog;
import com.xianbeiying.app.ckgl.util.ToastUtil;

import cz.msebera.android.httpclient.Header;

/**
 * 获取信息
 */
public class GetModel extends BaseModel {

    private AsyncHttpClient client;
    private RequestParams params;
    private Context context;

    public GetModel(Context context) {
        this.context = context;
        client = new AsyncHttpClient();
        params = new RequestParams();
//        MyApplication.IP= SharedPreferencesUtils.getStringDate("ip","120.26.96.123");
    }

    /**
     * 获取大棚的信息
     */
    public void QUWEYDEVS(boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("大棚地址", "http://"+MyApplication.IP+UrlBean.QUWEYDEVS + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVS, "", new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData(UrlBean.QUWEYDEVS, responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取对应ID大棚的信息
     */
    public void QUWEYDEVSDetauls(String k, long systemid, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("大棚详情", "http://"+MyApplication.IP+UrlBean.QURL + JsonBean.devjsonString(k, systemid) + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QURL, JsonBean.devjsonString(k, systemid), new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("大棚信息", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取阀门的状态信息
     */
    public void GET_SWITCH_STATUS(JsonDataBean jsonDataBean, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("阀门的状态", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + JsonBean.jsonString(jsonDataBean) + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, JsonBean.jsonString(jsonDataBean), new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("阀门状态返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("阀门信息", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取空气温湿度
     * SYSTEMID:系统编号
     * RTUID:控制器编号 0
     * EQPTYPE：设备类型 74
     * EQPID：设备ID 0
     */
    public void GET_AIRTEMPHUM(int SYSTEMID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String mm = JsonBean.wdString("GET_AIRTEMPHUM", SYSTEMID);
        LogUtils.e("获取空气温湿度", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + mm + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, mm, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("空气温湿度返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("空气温湿度", responseBody);

            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取土壤湿度
     * SYSTEMID:系统编号
     * RTUID:控制器编号
     * EQPTYPE：设备类型 65
     * EQPID：设备ID
     */
    public void GET_SOILHUM(int SYSTEMID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String mm = JsonBean.wdString("GET_SOILHUM", SYSTEMID);
        LogUtils.e("获取土壤湿度", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + mm + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, mm, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("土壤湿度返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("土壤湿度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取土壤温度
     * SYSTEMID:系统编号
     * RTUID:控制器编号
     * EQPTYPE：设备类型 64
     * EQPID：设备ID
     */
    public void GET_SOILTEMP(int SYSTEMID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String mm = JsonBean.wdString("GET_SOILTEMP", SYSTEMID);
        LogUtils.e("获取土壤温度", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + mm + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, mm, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("土壤温度返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("土壤温度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取光照强度
     * SYSTEMID:系统编号
     * RTUID:控制器编号
     * EQPTYPE：设备类型 80
     * EQPID：设备ID
     */
    public void GET_BEAMSTRENGTH(int SYSTEMID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String mm = JsonBean.wdString("GET_BEAMSTRENGTH", SYSTEMID);
        LogUtils.e("获取光照强度", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + mm + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, mm, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("光照强度返回值", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("光照强度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 查询周期性计划
     * SYSTEMID:系统编号
     * CODE:计划类型编号，值为0
     */
    public void QUERY_CYCLEPLANS(String k, long SYSTEMID, int CODE, boolean isDiaylog) {
//       final DialogUtile dialogUtile=new DialogUtile();
//        if (isDiaylog) {
//            DialogUtile.showLoading(context);
//
//        }
        final MyDialog myDialog=new MyDialog(context, R.style.custom_dialog_style);
        if (isDiaylog) {
//            DialogUtile.showLoading(context);
            myDialog.showView();
        }
        String url = JsonBean.zqPlantString(k, SYSTEMID, CODE);
        LogUtils.e("查询周期", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                Log.e("查询周期返回值", new String(responseBody));
//                myDialog.closeDialog();
                //函数返回值
                GetModel.this.onCallBackData("查询周期", responseBody);

            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                myDialog.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                myDialog.closeDialog();
            }
        });
    }

    /**
     * 查询阀门智能计划
     * SYSTEMID:系统编号
     * CODE:计划类型编号，值为1
     */
    public void QUERY_TRIGGERPLANS(String k, long SYSTEMID, int CODE, boolean isDiaylog) {
       final MyDialog myDialog=new MyDialog(context, R.style.custom_dialog_style);
        if (isDiaylog) {
//            DialogUtile.showLoading(context);
              myDialog.showView();
        }
        String url = JsonBean.zqPlantString(k, SYSTEMID, CODE);
        LogUtils.e("查询智能", "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUWEYDEVSDEFAULT, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
//                myDialog.closeDialog();
                Log.e("查询智能", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("查询智能", responseBody);
//                DialogUtile.closeDialog();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
//                DialogUtile.closeDialog();
                myDialog.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
            @Override
            public void onFinish() {
                super.onFinish();
                myDialog.closeDialog();
            }
        });
    }
    /**
     * 实时监控信息
     */
    public void QUERY_CROPSTEP(String k, int SYSTEMID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.dapengQuertString(k, SYSTEMID);
        LogUtils.e("实时监控信息", "http://"+MyApplication.IP+UrlBean.QUERY_CROPSTEP + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUERY_CROPSTEP, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("实时监控信息", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("实时监控信息", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 公告信息
     */
    public void GETNotice(String url, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("公告信息", "http://"+MyApplication.IP+UrlBean.GONGGAO + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GONGGAO + url, "", new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("公告信息", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("公告信息", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
//                ToastUtil.showInfo(context, "加载失败");
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }


    /**
     * 个人中心中
     * 我的收藏
     */
    public void GETCOLLECT(String k,int  USERID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.quercollectString(k,USERID);
        LogUtils.e("我的收藏", "http://"+MyApplication.IP+UrlBean.QUESTCOLLECT + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.QUESTCOLLECT, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("我的收藏", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("我的收藏", responseBody);
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 个人中心中
     * 我的消息
     */
    public void GETMYMESSAGE(String url, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        LogUtils.e("我的消息", "http://"+MyApplication.IP+UrlBean.GETMESSAGE + url + "======");
        HttpPostManger.post(context,"http://"+MyApplication.IP+UrlBean.GETMESSAGE+url, "", new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("我的消息", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("我的消息", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }
    /**
     * 获取省
     */
    public void GETProvice(String k, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.oneString(k);
        LogUtils.e("所有的省", "http://"+MyApplication.IP+UrlBean.GET_ALL_ADDRESS + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_ALL_ADDRESS, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("所有的省", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("所有的省", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取所有农作物
     */
    public void GETALLCrops(String k, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.oneString(k);
        LogUtils.e("农作物", "http://"+MyApplication.IP+UrlBean.GET_CROPS + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_CROPS, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("农作物", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("农作物", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 查询大棚
     */
    public void GETQueryGreenhouse(String k, int SYSTEMID, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.dapengQuertString(k, SYSTEMID);
        LogUtils.e("查询大棚", "http://"+MyApplication.IP+UrlBean.GET_GREENHOUSE + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_GREENHOUSE, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("查询大棚", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("查询大棚", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }


    //查询某一个时间段时间范围的光照强度
    public void GET_BEAM_STRENGTH(String k, int SYSTEMID, String BEGINDATETIME, String ENDDATETIME, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.timeDuanString(k, SYSTEMID, BEGINDATETIME, ENDDATETIME);
        LogUtils.e("光照强度", "http://"+MyApplication.IP+UrlBean.GET_BEAM_STRENGTH + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_BEAM_STRENGTH, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("光照强度", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("光照强度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    //查询某一个时间段时间范围的空气温度
    public void GET_AIR_TEMP(String k, int SYSTEMID, String BEGINDATETIME, String ENDDATETIME, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.timeDuanString(k, SYSTEMID, BEGINDATETIME, ENDDATETIME);
        LogUtils.e("空气温度", "http://"+MyApplication.IP+UrlBean.GET_AIR_TEMP + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_AIR_TEMP, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("空气温度", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("空气温度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    //查询某一个时间段时间范围的空气湿度
    public void GET_AIR_HUMIDITY(String k, int SYSTEMID, String BEGINDATETIME, String ENDDATETIME, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.timeDuanString(k, SYSTEMID, BEGINDATETIME, ENDDATETIME);
        LogUtils.e("空气湿度", "http://"+MyApplication.IP+UrlBean.GET_AIR_HUMIDITY + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_AIR_HUMIDITY, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("空气湿度", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("空气湿度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    //查询某一个时间段时间范围的土壤温度
    public void GET_SOIL_TEMP(String k, int SYSTEMID, String BEGINDATETIME, String ENDDATETIME, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.timeDuanString(k, SYSTEMID, BEGINDATETIME, ENDDATETIME);
        LogUtils.e("土壤温度", "http://"+MyApplication.IP+UrlBean.GET_SOIL_TEMP + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_SOIL_TEMP, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("土壤温度", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("土壤温度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    //查询某一个时间段时间范围的土壤湿度
    public void GET_SOIL_HUMIDITY(String k, int SYSTEMID, String BEGINDATETIME, String ENDDATETIME, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.timeDuanString(k, SYSTEMID, BEGINDATETIME, ENDDATETIME);
        LogUtils.e("土壤湿度", "http://"+MyApplication.IP+UrlBean.GET_SOIL_HUMIDITY + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_SOIL_HUMIDITY, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("土壤湿度", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("土壤湿度", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    //获取时间
    public void GET_DATE(String k, int greenhoustid, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.dapengQuertString(k, greenhoustid);
        LogUtils.e("获取时间", "http://"+MyApplication.IP+UrlBean.GET_DATE + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_DATE, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("获取时间", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("获取时间", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取作物生长阶段信息
     */
    public void GET_CROP_STEP_INFO(String k, int PLANTTYPE, boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.getPlantGrow(k, PLANTTYPE);
        LogUtils.e("作物生长阶段信息", "http://"+MyApplication.IP+UrlBean.GET_CROP_STEP_INFO + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_CROP_STEP_INFO, url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("作物生长阶段信息", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("作物生长阶段信息", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取首页精选
     */
    public void JINGXUAN(String url,boolean isDiaylog) {
        LogUtils.e("首页精选", "http://"+MyApplication.IP+UrlBean.JINGXUN + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.JINGXUN+url,"", new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("首页精选", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("首页精选", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
//                ToastUtil.showInfo(context, "加载失败");
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }

    /**
     * 获取添加后的生成阶段
     */
    public void GET_CROP_STEP_ALL_INFO(String k,boolean isDiaylog) {
        if (isDiaylog) {
            DialogUtile.showLoading(context);
        }
        String url = JsonBean.oneString(k);
        LogUtils.e("生成阶段", "http://"+MyApplication.IP+UrlBean.GET_CROP_STEP_ALL_INFO + url + "======");
        HttpPostManger.post(context, "http://"+MyApplication.IP+UrlBean.GET_CROP_STEP_ALL_INFO,url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                //关闭加载
                DialogUtile.closeDialog();
                Log.e("生成阶段", new String(responseBody));
                //函数返回值
                GetModel.this.onCallBackData("生成阶段", responseBody);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                //关闭加载
                DialogUtile.closeDialog();
                LogUtils.e("返回值", "----------------" + statusCode);
                if(statusCode==0){
                    ToastUtil.showInfo(context,"无法连接平台");
                }else if(statusCode==302){
                    MyApplication.isLogin=false;
//                    ToastUtil.showInfo(context,"请先登录");
                }else{
                    ToastUtil.showInfo(context,"无法连接平台");
                }
            }
        });
    }


}
